<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="125px">
      <el-form-item label="学员编号" prop="stuCode">
        <el-input v-model="queryParams.stuCode" placeholder="请输入学员编号" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="学员姓名" prop="stuName">
        <el-input v-model="queryParams.stuName" placeholder="请输入学员姓名" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="时间筛选">
        <el-date-picker v-model="queryParams.createTime" style="width: 240px" value-format="yyyy-MM-dd" type="daterange"
          range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期"></el-date-picker>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-table v-loading="loading" :data="planClassList">
      <el-table-column label="门店编号" align="center" prop="storeCode" width="120px" />
      <el-table-column label="门店名称" align="center" prop="storeName" />
      <el-table-column label="学员编号" align="center" prop="stuCode" width="120px" />
      <el-table-column label="学员姓名" align="center" prop="stuName" />
      <el-table-column label="使用学时" align="center" prop="learnNum">
        <template slot-scope="scope">
          {{ scope.row.learnNum }} /时
        </template>
      </el-table-column>
      <el-table-column label="学管姓名" align="center" prop="leaName" />
      <el-table-column label="教练姓名" align="center" prop="coaName" />
      <el-table-column label="上学时间" align="center" prop="upClassTime" />
      <el-table-column label="正式课/试听课-分润金额" align="center" prop="salary" width="180px" >
        <template slot-scope="scope">
          {{ scope.row.salary }} /元
        </template>
      </el-table-column>
      <el-table-column label="复习课分润金额" align="center" prop="perSalary">
        <template slot-scope="scope">
          {{ scope.row.perSalary }} /元
        </template>
      </el-table-column>
    </el-table>
    <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
      @pagination="getList" />

  </div>
</template>

<script>
import { listPlanClass, getPlanClass, delPlanClass, addPlanClass, updatePlanClass } from "@/api/course/planClass";
import store from '@/store'
import { findLoginRoleId } from '@/api/login'

export default {
  name: "PlanClass",
  data() {
    return {
      // 遮罩层
      loading: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 排课信息表格数据
      planClassList: [],
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        stuCode: null,
        stuName: null,
        className: null,
        classTypeName: null,
        storeCode: null,
        storeName: null,
        leaName: null,
        coaName: null,
        classTime: null,
        starTime: null,
        endTime: null,
        learnNum: null,
        teachMethod: null,
        classStatus: null,
        createBy: null,
      },
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询排课信息列表 */
    getList() {
      this.loading = true;
      const stuId = this.$route.query.stuId;
      if (stuId) {
        this.queryParams.stuId = stuId; // 如果有学员ID，则设置查询参数
      } else {
        this.queryParams.stuId = null; // 否则清除学员ID
      }
      listPlanClass(this.queryParams).then(response => {
        this.planClassList = response.rows;
        this.total = response.total;
        this.loading = false;
        this.$router.replace({ path: this.$route.path });
      });
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        orderCode: null,
        stuId: null,
        stuCode: null,
        stuName: null,
        className: null,
        classTypeId: null,
        classTypeName: null,
        storeUserId: null,
        storeCode: null,
        storeName: null,
        orderType: null,
        leaId: null,
        leaName: null,
        coaId: null,
        coaName: null,
        salary: null,
        perSalary: null,
        classTime: null,
        starTime: null,
        endTime: null,
        learnNum: null,
        teachMethod: null,
        classStatus: null,
        review: null,
        learnRemark: null,
        coachRemark: null,
        coachOrderStatus: null,
        offFormal: null,
        offTest: null,
        createBy: null,
        createTime: null,
        updateBy: null,
        updateTime: null,
        delFlag: null
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
  }
};
</script>
